<html>
    <head>
        <title>宅萌视界</title>
        <meta charset="utf-8">
    </head>
    <body>
        <form method="post" action="search.php">
            <input type="text" name="search" style="width:75%;height:40px">
            <button type="submit">搜索</button>
        </form>
<?php
include_once("admin/conn.php");
$sql_total="select count(*) from video where is_del =1";
$query0 = mysqli_query($conn,$sql_total);
while($row0 = mysqli_fetch_array($query0)){
    $total = $row0[0];
}
$total_pages = ceil($total / 10);
$page = !empty($_GET['page']) ? (int)$_GET['page'] : 1;
$limit = 10; // 每页显示的数量
$offset = ($page - 1) * $limit;
$sql="select * from video where is_del = 1 order by name desc limit 10 offset ".$offset;

$query = mysqli_query($conn,$sql);
    while($row = mysqli_fetch_array($query)){  
        $id=$row['id'];   
?>
        <h1><a href="detail.php?id=<?php echo $row['id'];?>"><?php echo $row['name'];?></a></h1>
        <div>
           <a href="detail.php?id=<?php echo $row['id'];?>"><img src="admin/<?php echo $row['img'];?>"></a>
        </div>
<?php
    }
    // 显示分页链接
for ($i = 1; $i <= $total_pages; $i++) {
    echo '<a href="?page=' . $i . '">' . $i . '</a> ';
}
?>      
    </body>
</html>
